package com.zut.edu.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.qmuiteam.qmui.layout.QMUIRelativeLayout;
import com.zut.edu.R;
import com.zut.edu.bean.Chart;
import com.zut.edu.widget.ColumnChartTool;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import lecho.lib.hellocharts.view.ColumnChartView;

public class StatisticsSecondFragment extends Fragment {
    @BindView(R.id.ss_num)
    TextView ssnum;
    @BindView(R.id.ss_text)
    QMUIRelativeLayout sstext;
    @BindView(R.id.ss_chart)
    QMUIRelativeLayout sschart;
    @BindView(R.id.ss_column_Chart)
    ColumnChartView sscolumnChart;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_statisticssecond,container,false);
        ButterKnife.bind(this,view);
        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        setLayout();
        initColumnChart();
    }

    private void initColumnChart(){
        List<Chart> DataList=new ArrayList<>();
        int sum=0;
        int[] num = new int[]{18,36,28,13,44,25,43,23,17,8,41,11};
        for (int i = 0; i < 12; i++) {
            DataList.add(new Chart((float) (num[i]), i + "月"));
            sum=sum+num[i];
        }
        ColumnChartTool.setChartViewData(DataList,sscolumnChart);
        ssnum.setText("审核人数"+sum+"人");
    }

    private void setLayout(){
        sstext.setRadius(25);
        sstext.setShadowColor(getResources().getColor(R.color.qmui_config_color_black));
        sstext.setAlpha(1.0f);
        sstext.setElevation(20);

        sschart.setRadius(25);
        sschart.setShadowColor(getResources().getColor(R.color.qmui_config_color_black));
        sschart.setAlpha(1.0f);
        sschart.setElevation(20);

    }
}
